package com.sjb.cp.model.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import lombok.Getter;

/**
 * @Author:sjb
 * @CreateTime:2025-02-14
 * @Description: 空间类型枚举
 * @Version：1.0
 */
@Getter
public enum SpaceTypeEnum {


    PRIVATE("私有空间",0),
    TEAM("团队空间",1);

    private final String text;

    private final int value;

    private SpaceTypeEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取空间类型枚举
     * @param value
     * @return
     */
    public static SpaceTypeEnum getTypeEnumByValue(int value){
        if (ObjectUtil.isNull(value)){
            return null;
        }

        for (SpaceTypeEnum spaceTypeEnum : SpaceTypeEnum.values()) {
            if (spaceTypeEnum.getValue() == value){
                return spaceTypeEnum;
            }
        }
        return null;
    }
}
